package com.lxw.multidb.controller.dto;

import cn.tannn.jdevelops.result.bean.SerializableBean;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.List;

@Schema(description = "分页查询自定义分类表")
@ToString
@Getter
@Setter
public class DbConnectionRequest extends SerializableBean<DbConnectionRequest> {

    /**
     * 数据库类型
     */
    @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "数据库类型不允许为空")
    private String dbType;

    /**
     * ip
     */
    @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "数据库类型不允许为空")
    private String host;

    /**
     * 端口
     */
    @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "数据库类型不允许为空")
    private Integer port;

    /**
     * 用户名
     */
    @Schema(description = "用户名", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "用户名不允许为空")
    private String username;

    /**
     * 密码
     */
    @Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "密码不允许为空")
    private String password;

    /**
     * 数据库名
     */
    @Schema(description = "数据库名")
    private String databaseName; // 可选

    /**
     * 表名
     */
    @Schema(description = "表名")
    private String tableName;    // 可选

    /**
     * SQL where 条件，为空则查所有，例如: id > 10 AND status = '1'
     */
    @Schema(description = " SQL where 条件，为空则查所有，例如: id > 10 AND status = '1'")
    private String condition;


    /**
     * 排序字段，没有默认id
     */
    @Schema(description = "排序字段,没有默认id")
    private String sortField = "id";


    /**
     * 排序方式（0.升序，1.倒叙，默认0）
     */
    @Schema(description = "排序方式（0.升序，1.倒叙，默认0）")
    private Integer sortType = 0;


    /**
     * 映射规则
     */
    private List<FieldMappingDTO> fieldMappings;

    private Integer pageIndex = 1;

    private Integer pageSize = 10;
}
